<template>
	<view>
		<u-navbar title="消息"  :autoBack="true" placeholder leftIconSize="22px" >
		</u-navbar>
		<!-- 	<u-navbar title="消息" :safeAreaInsetTop="true" placeholder>
			<view class="u-nav-slot" slot="left">
				<u-icon name="arrow-left" size="19"></u-icon>
			</view>
		</u-navbar> -->
		<view class="information" v-for="item in list">
			<view class="title">
				<view class="title_left">
					<view class="title_info">
						<view class="">
							<image src="../../static/mine/information.png" mode=""></image>
						</view>
						<view>
							<text>{{item.title}}</text>
						</view>
					</view>
				</view>
				<view class="title_right">{{item.createtime}}</view>
			</view>
			<view class="information_content">
				<text>{{item.content}}</text>
			</view>
		</view>
		<view class="loadingText">{{loadingText}}</view>
	</view>
</template>

<script>
	// import {
	//  noticeList
	// } from '../../api/user.js'
	// import config from '@/api/config.js'
	export default {
		data() {
			return {
				list: [],
				page: 1,
				loadingText: '',
			}
		},
		onLoad() {
			this.getList();
		},
		onPullDownRefresh() {
			this.page = 1
			this.getList();
		},
		onReachBottom() {
			this.loadingText = "上拉显示更多"
			this.getMoreList();
		},
		methods: {
			
			getList() {
				this.$api.post('/api/user/noticeList', {
					page: this.page,
				}).then((res) => {
					if (res.code == 1) {
						this.info = res.data;
						if (res.data.list.length == 0 || res.data.list == null) {
							this.loadingText = '-- 暂无更多 --'
							return false;
						}
						this.list = res.data.list;
						uni.stopPullDownRefresh()
						this.page++
					} else if (res.code == 401) {
						this.LoadingMsg(res.msg);
						setTimeout(() => {
							uni.hideLoading();
							uni.navigateTo({
								url: '../login/login'
							})
						}, 1500);
			
					} else {
						this.toastMsg(res.msg);
					}
				})
			},
			getMoreList() {
				this.loadingText = '-- 正在加载 --'
				this.$api.post('/api/rider/user/orderCount',{
					token: this.token,
					page: this.page,
					type:this.type
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data;
						if (res.data.list.length == 0 || res.data.list == null) {
							this.loadingText = '-- 暂无更多 --'
							return false;
						}
						var newlist = res.data.list;
						this.list = this.list.concat(newlist)
						this.page++
					}else if (res.code == 401) {
						this.LoadingMsg(res.msg);
						setTimeout(() => {
							uni.hideLoading();
							uni.navigateTo({
								url: '../login/login'
							})
						}, 1500);
			
					} else {
						this.toastMsg(res.msg);
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #EFF1F5;
	}
</style>
<style lang="scss" scoped>
	.information {
		margin: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}

	.loadingText {
		padding: 20rpx 0 40rpx 0;
		text-align: center;
		color: #310D05;
		font-size: 28rpx;
	}

	.title {
		margin: 10rpx 30rpx 0 30rpx;
		display: flex;
		justify-content: space-between;
		padding-top: 30rpx;

		.title_left {
			image {
				width: 60rpx;
				height: 60rpx;
			}
		}

		.title_info {
			display: flex;

			view {
				margin-right: 20rpx;
			}
		}
	}

	.information_content {
		padding: 30rpx;
	}
</style>
